<?php

/**
 * @Description    用户验证
 * @Author         zhaojiping
 * @Copyright      山东艾思软件科技有限公司(https://www.aisisofit.cn)
 * @Date           2022/2/7
 * @CreateBy       VS Code
 */

namespace app\core\validate;

use think\Validate;

class CoreUser extends Validate {

    protected $rule = [
        'avatar'        => 'max:255',
        'sn'            => 'length:5,15|unique:core_user',           // 编号
        'nickname'      => 'require|length:2,10',
        'username'      => 'require|length:4,20|unique:core_user',
        'mobile'        => 'require|mobile|unique:core_user',
        'title_id'      => 'require|number|between:1,99999',
        'role_id'       => 'require|number|between:1,99999',
        'department_id' => 'require|number|between:1,99999',
        'usable'        => 'number|between:0,9',
        'is_manage'     => 'number|between:0,9',
        'email'         => 'max:50',
    ];

    protected $field = [
        'sn'       => '员工编号',
        'nickname' => '员工姓名',
        'mobile'   => '手机号码',
        'email'    => '用户邮箱',
    ];

    protected $message = [
        'avatar.max'       => '头像地址最大长度为255个字符',
        'username.require' => '请输入登录名称',
        'username.length'  => '登录名称4到20个字符',
        'nickname.length'  => '员工姓名2到10个字符',
        'username.unique'  => '登录名称已经存在',
        'role_id.require'  => '请选择用户所属权限组',
        'role_id.number'   => '所属权限组有误, 未知原因',
        'is_manage'        => '部门负责人输入有误',
        'department_id'    => '请选择用户职位',
        'title_id'         => '请选择岗位',
    ];

    public function sceneModInfo() {
        return $this->only(['nickname', 'mobile', 'avatar'])->remove('mobile', 'require');
    }
}
